let quantity = 2;
let product = {
  price: 100,
  quantity,
};

let amount = 0;
function getAmount() {
  amount = product.price * product.quantity;
}

console.log("🚀 ~ file: Object.defineProperty.js:6 ~ amount:", amount);

Object.defineProperty(product, "quantity", {
  get() {
    console.log("🚀 ~ file: Object.defineProperty.js:14 ~ get ~ get:");
    return quantity;
  },
  set(value) {
    console.log("🚀 ~ file: Object.defineProperty.js:14 ~ set ~ set:");
    quantity = value;
    getAmount();
  },
});

product.quantity = 10;
console.log("🚀 ~ file: Object.defineProperty.js:16 ~ amount:", amount);
